<template>
    <div class="home_wrap">
        <div class="left">
            <img src="@/assets/img/logo.png" alt="" srcset="" />
            <div class="pingtai">学生信息成绩管理系统</div>
        </div>
        <div class="right">
            <ul class="list">
                <li @click="goKeFu"><a href="#">在线客服</a></li>
                <li @click="goAnQuan"><a href="#">安全中心</a></li>
                <li @click="goWenTi"><a href="#">常见问题</a></li>
                <!-- info当有登录的用户名时就应该是该用户名 没有的话就是登录 this.$store.state.user_name -->
                <li @click="goLogin"><a href="#">{{ info }}</a></li>
                <li @click="exit"><a href="#">退出</a></li>
            </ul>
        </div>
    </div>
</template>

<script>
export default {
    computed: {
        info() {
            return this.$store.state.user_name ? this.$store.state.user_name : "登录";
        },
    },
    //流程：先注册再登录 用户名在主页显示  用户名在登录 login当中输入  再在主页 home组件当中显示
    methods: {
        goKeFu() {
            this.$router.push({
                name: "kefu",
            })
        },
        goAnQuan(){
            this.$router.push({
                name: "anquan",
            })
        },
        goWenTi(){
            this.$router.push({
                name: "wenti",
            })
        },
        goLogin() {
            //判断 当显示登录时点击跳到登录页面  当显示用户名时点击进入个人中心
            if (!this.$store.state.user_name) {
                this.$router.push({
                    name: "login",
                })
            } else {
                this.$router.push({
                    name: "personcenter",
                })
            }
        },
        exit() {
            // 退出 关闭当前的浏览器标签
            // 清除state当中的数据 localStorage和sessionStorage
            localStorage.clear();
            sessionStorage.clear();

            //跳到一个空白的页面  about:blank
            // window.open("about:blank", "_self");
            //跳到首页未登录之前的状态
            window.open("_self");

            window.close();
        },
    },
};
</script>

<style lang="scss" scoped>
.home_wrap {
    display: flex;
    justify-content: space-between;

    .left {
        display: flex;
        align-items: center;

        img {
            width: 100px;
            height: 100px;
        }

        .pingtai {
            font-size: 30px;
            font-weight: 700;
            display: flex;
            align-items: center;
        }
    }

    .right {
        display: flex;
        align-items: flex-end;

        .list {
            display: flex;

            li {
                padding-right: 15px;
                padding-bottom: 15px;

                a {
                    text-decoration: none;
                    color: black;
                }

                a:hover {
                    color: red;
                }
            }
        }
    }
}
</style>